package com.wukang.photovoltaicinspectionpictures.utils

import android.os.SystemClock
import android.view.View


/**
 * 点击防抖
 * @author wukang
 */
abstract class DebounceListener(private val interval: Long = 1000L) : View.OnClickListener {
    private var lastClickTime: Long = 0

    override fun onClick(v: View) {
        val currentTime = SystemClock.elapsedRealtime()
        if (currentTime - lastClickTime > interval) {
            onDebounceClick(v)
            lastClickTime = currentTime
        }
    }

    protected abstract fun onDebounceClick(v: View)
}
